package cn.gz.demo.ui;


import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.View;

import androidx.databinding.DataBindingUtil;

import cn.gz.demo.R;
import cn.gz.demo.databinding.ImageOperationBinding;
import cn.gz.demo.ui.base.BaseActivity;
import cn.gz.demo.utils.BitmapUtils;

public class ImageOperationActivity extends BaseActivity {
    private ImageOperationBinding binding;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = DataBindingUtil.setContentView(this, R.layout.activity_image_operation);

        binding.btn1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Bitmap bitmapOne = BitmapFactory.decodeResource(context.getResources(), R.mipmap.pic_leadpage_1);
                Bitmap bitmapTwo = BitmapFactory.decodeResource(context.getResources(), R.mipmap.alpha_bg);
                Bitmap bitmap = BitmapUtils.mergeThumbnailBitmap_1(bitmapOne, bitmapTwo, 255);
                binding.image.setImageBitmap(bitmap);
            }
        });
        binding.btn2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Bitmap bitmapOne = BitmapFactory.decodeResource(context.getResources(), R.mipmap.pic_leadpage_1);
                Bitmap bitmapTwo = BitmapFactory.decodeResource(context.getResources(), R.mipmap.pic_yindao);
                Bitmap bitmap = BitmapUtils.combineImage(bitmapOne, bitmapTwo);
                binding.image.setImageBitmap(bitmap);
            }
        });
        binding.btn3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Bitmap bitmap = BitmapUtils.getViewBitmap(binding.xcxLayout);
                binding.image.setImageBitmap(bitmap);
            }
        });
    }
}
